<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <script src="vue.js"></script>
  </head>
  <body>
    <div id="root">
      <!-- 直接调用父组件 -->
      <counter @click.native="handleClick"></counter>
    </div>

    <script>
      var myCounter = {
        template: '<div>点击</div>',
        methods: {
          handleClick: function() {
            alert('子组件点击');
          }
        }
      };

      var vm = new Vue({
        el: '#root',
        components: {
          counter: myCounter
        },
        methods: {
          handleClick: function() {
            alert('父组件点击');
          }
        }
      });
    </script>
  </body>
</html>
